package rule_window

import (
	"file_explorer/view/packed_widgets"
	"file_explorer/view/store"

	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/container"
)

type RuleWindow struct {
	fyne.Window

	tabCtx *store.RenameTabContext
}

func NewRuleWindow(tabCtx *store.RenameTabContext, onSubmit func()) *RuleWindow {
	window := &RuleWindow{
		tabCtx: tabCtx,
		Window: packed_widgets.NewWindow("重命名规则"),
	}

	// 创建各种规则tab
	tabs := container.NewAppTabs(
		window.newRuleAddTab(onSubmit),
		window.newRuleDeleteTab(onSubmit),
		window.newRuleReplaceTab(onSubmit),
		window.newRuleExtNameTab(onSubmit),
		window.newRuleSeqTab(onSubmit),
	)
	tabs.SetTabLocation(container.TabLocationLeading)

	window.SetContent(tabs)
	window.Resize(fyne.NewSize(400, 400))
	window.Show()

	return window
}
